/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ttt.nor2.smssender;

import com.ttt.nor2.db.Smstrans;
import com.ttt.nor2.util.ThaiUtil;

/**
 *
 * @author anuphabm
 */
public class QueryString {
    
    private Smstrans smst;

    public QueryString(Smstrans smst) {
        this.smst = smst;
    }

    public String getParam(){

        //http://tsms.ttt.co.th/sms/update_sms_nologin.pl?
        //user_id=9841&send_no_dis=035230420&type=20&lang=th&msgcnt=1&tel_no=0898441042&msg=ทดสอบSMSทดสอบ%20ทดสอบ
        //user_id=9848&send_no_dis=035230420&type=20&lang=th&msgcnt=1&tel_no=0860216262&msg=test
        if(ThaiUtil.checkMessageLang(smst.getMsgout()).equalsIgnoreCase("T")){
            smst.setLang("th");
            smst.setMsgout(ThaiUtil.ASCII2Unicode(smst.getMsgout()));
        }else{
            smst.setLang("en");
        }
        StringBuffer stb = new StringBuffer();
        stb.append("user_id=").append(smst.getUsername()).append("&send_no_dis=").append(smst.getSender());
        stb.append("&type=").append(smst.getType()).append("&lang=").append(smst.getLang()).append("&msgcnt=1");
        stb.append("&tel_no=").append(smst.getAni()).append("&msg=").append(smst.getMsgout());
        String qStr =  stb.toString();
        return qStr;
    }



}
